<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\ConfigSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '基础配置列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<style type="text/css">
    td {text-align: center;}
</style>
<div class="config-index">

    <p>
        <?= Html::a('创建配置', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],

            [
                'attribute' => 'id',
                'value' => 'id',
                'headerOptions' => ['width' => '50'],
            ],
             [
                'format' => 'raw',
                'attribute' => 'cid',
                'value' => function($model) {
                    if($model->cid == 1){
                        return '<span class="btn btn-xs btn-primary">基本设置</span>';
                    }elseif($model->cid == 2){
                        return '<span class="btn btn-xs btn-primary">seo</span>';
                    }else{
                        return '';
                    }
                },
                'filter' => ['1' => '基本设置', '2' => 'seo'],
                'headerOptions' => ['width' => '100'],
            ],
            [
                'format' => 'raw',
                'attribute' => 'type',
                'value' => function($model) {
                    if($model->type == 'img'){
                        return '<span class="btn btn-xs btn-info">图片</span>';
                    }else{
                        return '<span class="btn btn-xs btn-info">文本</span>';
                    }
                },
                'filter' => ['text' => '文本', 'img' => '图片'],
                'headerOptions' => ['width' => '100'],
            ],
            // 'key',
            'title',
            [
                'format' => 'raw',
                'attribute' => 'value',
                'value' => function($model){
                    return "<p style='width: 350px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>".$model->value."</p>";
                },
                'headerOptions' => ['width' => '350'],
            ],
            'remark',
            [
                'attribute' => 'sort',
                'value' => 'sort',
                'headerOptions' => ['width' => '50'],
            ],
            [
                'format' => 'raw',
                'attribute' => 'update_time',
                'value' => function($model) {
                    return date('Y-m-d H:i', $model->update_time);
                },
            ],
            
        ],
    ]); ?>


</div>
